
#include "MyCPUFile.h"

enum WINDOW_SIZE
{
    WIN_WID = 200,
    WIN_HEI = 200
};

int main()
{
    try
    {
        txCreateWindow(WIN_WID, WIN_HEI);

        CPU cpu;

        FILE* input = fopen("Formula.txt", "r");
        FILE* output = fopen("Formula_.txt", "w");

        assemble(input, output);

        fclose(output);
        fclose(input);

        double y = 0;

        for(double x = -WIN_WID/2; x <= WIN_WID/2; x += 0.5)
        {
            cpu.set_x(x);
            double y = cpu.run("Formula_.txt");

            //cout << "Now x is " << x + WIN_WID/2 << " and y is " << -(y/100) + WIN_HEI/2 << std::endl;

            txSetPixel(x + WIN_WID/2, -(y/50) + WIN_HEI/2, TX_WHITE);
        }
    }
    catch(const char* exc)
    {
        $r cout << exc; $d
    }
    catch(exception exc)
    {
        cout << exc.what();
    }
    catch(...)
    {
        cout << "Shit happens!";
    }

    return 0;
}

